import static org.junit.Assert.*;

import org.junit.Test;


public class TestThreeNCalculator {	
	long startNum[] = {1, 100, 201, 900};
	long endNum[] = {10, 200, 210, 1000};
	long result[] = {20, 125, 89, 174};
	
	@Test
	public void testCalculateCycleLength() {
		long result = 0;
		ThreeNCalculator cal = new ThreeNCalculator(1, 10);
		result = cal.calculateCycleLength(22);
		assertEquals(16, result);		
	}
	
	@Test
	public void testSetInput() {
		for(int i=0; i < startNum.length ; ++i) {
			ThreeNCalculator cal = new ThreeNCalculator(startNum[i], endNum[i]);
			assertEquals(startNum[i], cal.getStartNum());
			assertEquals(endNum[i], cal.getEndNum());
		}
	}
	
	@Test
	public void testSetReverseInput() {
		for(int i=0; i < startNum.length ; ++i) {
			ThreeNCalculator cal = new ThreeNCalculator(endNum[i], startNum[i]);
			assertEquals(startNum[i], cal.getStartNum());
			assertEquals(endNum[i], cal.getEndNum());
		}
	}
	
	@Test
	public void testGetMaxCycleLength() {
		for(int i=0; i < startNum.length ; ++i) {
			ThreeNCalculator cal = new ThreeNCalculator(startNum[i], endNum[i]);
			assertEquals(result[i], cal.getMaxCycleLength());
		}
	}
}
